/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {});

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1669628853313_3843';
  // config.nacosConfig = {
  //   // logger: console,
  //   // serverAddr: 'mse-260962d6-nacos-ans.mse.aliyuncs.com',
  //   // port: 8848,
  //   // namespace: 'fe-test',
  //   // serverAddr:appInfo.nacosConfig.serverAddr,
  //   // // serverAddr: 'mse-260962d6-nacos-ans.mse.aliyuncs.com',
  //   // // serverPort: 80,
  //   // serverPort: config.nacosConfig.port,
  //   // namespace: config.nacosConfig.namespace,
  // };
  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    jwt: {
      secret: 'uid',
    },
    cors: {
      origin: '*',
      allowMethods: 'GET, HEAD, PUT, POST, DELETE, PATCH',
      credentials: true,
    },
    security: {
      csrf: {
        // 判断是否需要 ignore 的方法，请求上下文 context 作为第一个参数
        ignore: () => true,
      },
    },

    multipart: {
      mode: 'file',
      fileSize: '50mb',
      whitelist: [
        '.png',
        '.gif',
        '.jpg',
        '.jpeg',
        '.xlsx',
        '.xls',
        '.html',
        '.htm',
      ],
    },
  };
  //  userConfig.
  return {
    ...config,
    ...userConfig,
  };
};
